package com.pomelo.tiku.impls;

import com.pomelo.tiku.beans.RegisterBean;
import com.pomelo.tiku.constants.UrlConstants;
import com.pomelo.tiku.interfaces.Contract;

import java.util.HashMap;

/**
 * @author liuxiangwang
 * @date .
 */
public class RegisterPresenter implements Contract.IRegisterPresenter {
    private Contract.IRegisterModel iRegisterModel;
    private Contract.IRegisterView iRegisterView;


    public RegisterPresenter(Contract.IRegisterModel model, Contract.IRegisterView view) {
        this.iRegisterModel = model;
        this.iRegisterView = view;
    }


    @Override
    public void request(String url, HashMap<String,String> header, HashMap<String,String> data) {
        iRegisterModel.register(url, header, data, true, new Contract.IRegisterModel.IRegisterResult() {
            @Override
            public void onStart() {
                iRegisterView.showLoading();
            }

            @Override
            public void onSuccess(RegisterBean data) {
                iRegisterView.registerSuccess(data);
                iRegisterView.stopLoading();
            }

            @Override
            public void onFailed(String message) {
                iRegisterView.registerFailed(message);
                iRegisterView.stopLoading();
            }

            @Override
            public void onHttpFailed(String message) {
                iRegisterView.registerFailed(message);
                iRegisterView.stopLoading();
            }
        });
    }
}
